summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/am/applet_manager.h
blob: 4875de309ea2e2b712d57f91e8b6bf2d967a725c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later

#pragma once

#include <map>
#include <mutex>

#include "core/hle/service/am/applet.h"

namespace Core {
class System;
}

namespace Service::AM {

enum class LaunchType {
    FrontendInitiated,
    ApplicationInitiated,
};

struct FrontendAppletParameters {
    ProgramId program_id{};
    AppletId applet_id{};
    AppletType applet_type{};
    LaunchType launch_type{};
    s32 program_index{};
    s32 previous_program_index{-1};
};

class AppletManager {
public:
    explicit AppletManager(Core::System& system);
    ~AppletManager();

    void InsertApplet(std::shared_ptr<Applet> applet);
    void TerminateAndRemoveApplet(AppletResourceUserId aruid);

    void CreateAndInsertByFrontendAppletParameters(AppletResourceUserId aruid,
                                                   const FrontendAppletParameters& params);
    std::shared_ptr<Applet> GetByAppletResourceUserId(AppletResourceUserId aruid) const;

    void Reset();

    void RequestExit();
    void RequestResume();
    void OperationModeChanged();
    void FocusStateChanged();

private:
    Core::System& m_system;

    mutable std::mutex m_lock{};
    std::map<AppletResourceUserId, std::shared_ptr<Applet>> m_applets{};

    // AudioController state goes here
};

} // namespace Service::AM